<http://wiki.debian.org/QEMU#Setting_up_a_testing.2BAC8-unstable_system>
Follow the steps for making a disk image, downloading the business
-card CD, booting it in QEMU and running through the installer.
+card CD, booting it in QEMU and running through the installer. Note I
+used the QCOW format, since it is more efficient. Here are the steps
+I chose:
+
+ $ qemu-img create -f qcow2 debian.qcow 2G
+ $ qemu-kvm -hda debian.qcow -cdrom debian-testing-amd64-businesscard.iso -boot d -m 512
Test that the image works after installation too, before you start
modifying things below! Remember to remove the -cdrom and -boot
-options from the installation QEMU command.
+options from the installation QEMU command. It should just look like
+this:
+
+$ qemu-kvm -hda debian.qcow -m 512
+
Modifying the image
-------------------
You now have a disk image in debian.img, and the first partition
should be ext4.
-The first thing I did was mount the image, and move almost everythig
-(/boot, /var, /etc), except lost+found to a new directory "r0".
+The first thing I did was mount the image, and move the "read only"
+parts of the OS to a new directory "r0".
$ mkdir /mnt/debian
$ modprobe nbd max_part=8
$ mount /dev/nbd0p1 /mnt/debian/
$ cd /mnt/debian
$ mkdir r0
- $ DIRS="bin boot dev etc lib lib64 media mnt opt proc root run sbin selinux srv sys tmp usr var"
+ $ DIRS="bin dev etc lib lib32 lib64 media mnt opt proc root run sbin selinux srv sys tmp usr"
$ mv $DIRS r0
-Now with it still mounted, we need to move on to the next part -
-modifying the initrd.
+Note that /boot, /home and /var are left shared. Now with it still
+mounted, we need to move on to the next part - modifying the initrd.
Then I started hacking on the initrd, making understand how to chroot
to "r0". I ended up with two patches - one to util-linux, and one to
Now you have a modified "sys-utils/switch_root" binary. Let's next
patch the initrd and rebuild it:
+$ cd ..
+
Make a backup:
$ mkdir initrd
$ (cd initrd; find | cpio -o -H newc) | gzip > /mnt/debian/boot/initrd.img-3.0.0-1-amd64.new
$ mv /mnt/debian/boot/initrd.img-3.0.0-1-amd64{.new,}
+Unmount:
+
+ $ umount /mnt/debian
+
Running hacktree inside the system
----------------------------------